package com.hean.service;

import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import java.io.OutputStream;

public class FileService {
	public static void save(OutputStream outputStream,String content) throws Exception{
		outputStream.write(content.getBytes());
		outputStream.close();
	}
	
	public static String read(InputStream inputStream) throws Exception{
		ByteArrayOutputStream outputStream=new ByteArrayOutputStream();
		byte[] buffer=new byte[1024];
		int len=-1;
		while((len=inputStream.read(buffer))!=-1){
			outputStream.write(buffer, 0, len);
		}
		byte[] data=outputStream.toByteArray();
		outputStream.close();
		inputStream.close();
		return new String(data);
	}
}
